package com.fh.modules.shiro;

import com.fh.modules.system.entity.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * @Description:
 * @author： qiujunda
 * @date： 2019/10/13 22:35
 */
public class ShiroUtils {

    public static SysUser getUser(){
        return (SysUser) getShiroPrincipal();
    }

    public static Object  getShiroPrincipal(){
        try{
            return getShiroSubject().getPrincipal();
        }catch (Exception e){
            return null;
        }
    }

    public static Subject getShiroSubject(){
        try{
            return SecurityUtils.getSubject();
        }catch (Exception e){
            return null;
        }
    }
}
